﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace x.paypal.model
{
    public class PaymentDetailsRequest:IPaymentDetailsRequest
    {
        XDocument doc = null;
        XNamespace payPalNamespace = "http://svcs.paypal.com/types/ap";
        string request = "PaymentDetailsRequest"; 
        #region IPayPalPaymentDetailsRequest Members

        public IPaymentDetailsRequest CreateRequest()
        {
            doc = new XDocument
            (

               new XElement(payPalNamespace + request,
                   new XElement("requestEnvelope",
                   new XElement("errorLanguage", "en_US"))
                   ));

            return this; 
        }
        public IPaymentDetailsRequest WithPayKey(string payKey)
        {
            XElement a = new XElement("payKey",payKey);
            doc.Element(payPalNamespace + request).Add(a);
            return this;
        }

        public IPaymentDetailsRequest WithTrackingId(string trackingId)
        {
            XElement a = new XElement("trackingId", trackingId);
            doc.Element(payPalNamespace + request).Add(a);
            return this;
        }

        public IPaymentDetailsRequest WithTransactionId(string transactionId)
        {
            XElement a = new XElement("transactionId", transactionId);
            doc.Element(payPalNamespace + request).Add(a);
            return this;
        }

        public XElement AsXML
        {
            get
            {
                return XElement.Parse(doc.ToString());
            }
        }

        #endregion
    }
}
